import React, { Component } from 'react'
import {withRouter} from 'react-router-dom'

class Header extends Component {

  forward = ()=>{
    this.props.history.goForward()
  }
  back = ()=>{
    this.props.history.goBack()
  }

  render() {
    return (
      <div className="page-header">
        <h2>React Router Demo</h2>
        <button onClick={this.forward}>前进</button>&nbsp;
        <button onClick={this.back}>回退</button>
      </div>
    )
  }
}

export default withRouter(Header)
// withRouter:是一个函数，给【一般组件】加上【路由组件】的【三大属性】
//其返回值是一个新组建（一般组件加工后的组件）